from django.shortcuts import render
from django.http import HttpResponse, JsonResponse
from django.contrib.auth.models import User
from rest_framework import viewsets
from naonao.serializers import UserSerializer

# Create your views here.

class IndexViewSet(viewsets.ModelViewSet):
    queryset = User.objects.all()
    serializer_class = UserSerializer

    def list(self, request, *args, **kargs):
        r = request.META
        print(r)
        data = {'data': "hello"}
        return JsonResponse(data)

#  @api_view(['GET','POST'])
def TestViewSet(request):
    """
    定义index页面公共的view操作
    从这里发出url请求,寻求资源服务器的资源
    获取所有的学生信息的url: GET http://127.0.0.1:8001/students/
    """
    #  data = {'hello': "hello client!!!!"}
    return render(request, "index.html", locals())
    #  return HttpResponse("hello")
    #  return redirect()
